/**
 * describe:
 *
 * @author chaP
 * @date 2019/04/02
 */
package CodingTest.AC20190402;

import java.util.Stack;

public class MyQueue {
    Stack<Integer> s1 = new Stack<Integer>();
    Stack<Integer> s2 = new Stack<Integer>();
    public void MyQueue(){

    }
    public void push(int x){
        s1.push(x);
    }
    public int pop(){
        if(!s2.isEmpty()){
            return s2.pop();
        }
        while(!s1.isEmpty()){
            s2.push(s1.pop());
        }
        return s2.pop();

    }
    public int peek(){
        if(!s2.isEmpty()){
            return s2.peek();
        }
            while(!s1.isEmpty()){
                s2.push(s1.pop());
            }
            return s2.peek();

    }
    public boolean empty(){
        return s1.isEmpty()&&s2.isEmpty();
    }
}
